package com.summit.exam.servlet;

import com.summit.exam.dbdao.UserInfoDao;
import com.summit.exam.entity.UserInfoBean;

import java.io.IOException;
import java.io.Writer;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



public class ForgetUnameServlet extends HttpServlet{
	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
	doPost(request, response);
	}

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");

		String uname = request.getParameter("uname");

		UserInfoDao userInfoDao = new UserInfoDao();
		List<UserInfoBean> userInfoBean = userInfoDao.queryStudent(uname);

		try {
			Writer wrt = response.getWriter();
			if(userInfoBean != null && userInfoBean.size() != 0
					&& userInfoBean.get(0).getUserLoginName() != null){
				wrt.write("yes");
			}else{
				wrt.write("no");
			}
			wrt.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
}
